<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List"%>    
<%@ page import="minipost.post.model.Post"%>
<%@ page import="minipost.post.PostBean"%>

<%
	request.setCharacterEncoding("UTF-8");
	String typeKey = request.getParameter("type");
	PostBean postBean = new PostBean();
	String type = postBean.getTypeValue(typeKey);
	List<Post> list = postBean.getPostByType(type);
	
	if (list == null) {
%>
	<jsp:forward page="404.html"></jsp:forward>
<%
	} else {
%>    

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>栏目</title>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/public.js"></script>
</head>
<body>
    <div id="head">
    </div>
    <div class="clean"></div>
    <div id="nav">
        <div class="content">
            <div class="left">
                <ul>
                    <li class="active"><a href="index.jsp">首页</a></li>
                    <li><a href="category.jsp?type=home">国内</a></li>
                    <li><a href="category.jsp?type=abroad">国外</a></li>
                    <li><a href="category.jsp?type=society">社会</a></li>
                    <li><a href="category.jsp?type=tech">科技</a></li>
                </ul>
            </div>
            <div class="right" id="current_time"></div>
        </div>
    </div>
    <div class="clean"></div>
    <div class="list_row">
        <div id="list">
            <div class="list_head">
                <a class="list_head_item" href="index.jsp" title="">首页</a>
                <span class="list_head_item splash">&gt;</span>
                <a class="list_head_item" title=""><%= type%></a>
            </div>
            <div class="list_content">
                <ul>
                <%
               		int length = list.size();
            		for (int i = 0; i < length; ++i) {
            			Post currentPost = list.get(i);                	
                %>
                    <li><a href="single.jsp?id=<%= currentPost.getId()%>" title=""><span class="list_title"><%= currentPost.getPostTitle()%></span><span class="list_time"><%= currentPost.getPostDateAsString()%></span></a></li>
                    <% if ((i + 1) % 5 == 0) { %>
                    <li style="background: none;"></li>
                    <% } %>         
                <% } %>                  
                </ul>
            </div>

            <div class="list_page">
                <form method="get">
                <input type="hidden" name="cat" value="<?php echo get_query_var('cat');?>" />
                <span class="page_total">
                    第1页&nbsp;共1页&nbsp;<%= length%>条
                </span>
                <span class="page_item">
                    <a href="#>" title="首页">首页</a>
                </span>
                <span class="page_item">
                    <a href="#" title="末页">末页</a>
                </span>
                <span class="page_item">
                    <a href="#" title="">上一页</a>
                </span>
                <span class="page_item">
                    <a href="#" title="">下一页</a>
                </span>
                <span class="page_item">
                    <a href="j#" title="">跳转到</a>
                </span>
                
                <span class="page_item">
                    <input type="text" name="page" id="jump_page" />
                </span>
                <span class="page_item">
                    <input type="submit" value="跳转" id="jump_submit" />
                </span>
                </form>
            </div>
        </div>

        <div id="slider">
            <div class="slider_head">
                <span>推荐文档</span>
            </div>
            <div class="slider_content">
                <ul>
                <%
                	List<Post> all = postBean.getAllPosts();
                	length = all.size();
        			for (int i = 0; i < length; ++i) {
        				Post currentPost = all.get(i); 
                %>
                    <li><a href="single.jsp?id=<%= currentPost.getId()%>" title=""><%= i + 1%>.<%= currentPost.getPostTitle()%></a></li>
                <% } %>
                </ul>
            </div>
        </div>
    </div>
    <div class="clean"></div>
    <div id="foot">
        Copyright&copy;&nbsp;合肥工业大学网站设计基础
    </div>
</body>
</html>
<%
	}
%>